﻿$(window).ready(function() {
    $(window).load(function() {
        var authMode = $("#" + cbAuthMode).val();
        if (authMode == '2' || authMode == 2) {
            $("#" + txtUsername + ", #" + txtPassword).prop("readonly", false);
        } else {
            $("#" + txtUsername + ", #" + txtPassword).prop("readonly", true);
        }
    });

    $("#" + chkServer).click(function() {
        var cbSrv = $("#" + cbServer);
        var txtSrv = $("#" + txtServer);
        var chkState = $(this).prop("checked");
        if (chkState == true) {
            cbSrv.val("0").hide();
            txtSrv.val("").show().focus();
        } else {
            txtSrv.val("").hide();
            cbSrv.val("0").show();
        }
    });

    $("#" + cbServer).change(function() {
        var thisVal = $(this).val();
        if (!(thisVal == '0')) {
            $("#" + txtServer).val(thisVal);
        }
    });

    $("#" + cbAuthMode).change(function() {
        var thisval = $(this).val();
        if (!(thisval == '0' || thisval == 0 || thisval == '')) {
            if (thisval == '1' || thisval == 1) {
                $("#" + txtUsername + ", #" + txtPassword).val("").prop("readonly", true);
            } else {
                $("#" + txtUsername + ", #" + txtPassword).prop("readonly", false);
            }
        } else {
            $("#" + txtUsername + ", #" + txtPassword).val("").prop("readonly", true);
        }
    });

});